package com.houxiurong.service.impl;

import com.houxiurong.dao.UserDAO;
import com.houxiurong.entity.User;
import com.houxiurong.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by houxiurong on 2017/6/29.
 */
@Service
public class UserServiceImpl implements UserService {

    private Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    UserDAO userDAO;


    @Override
    public List<User> findAll() {
        return userDAO.findAll();
    }

    @Override
    public User getUserById(Integer id) {
        return userDAO.getOne(id);
    }

    @Override
    public User login(User user) {
        return userDAO.save(user);
    }

    @Override
    public User findUserByName(String name) {
        return userDAO.findByName(name);
    }

    @Override
    public Page<User> findByNameNot(String name, Pageable pageable) {
        return userDAO.findByNameNot(name, pageable);
    }

}
